package com.ikun.controller;

import com.ikun.pojo.Result;
import com.ikun.pojo.TbUserTask;
import com.ikun.service.UserTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Controller
public class UserTaskController {

    @Autowired
    UserTaskService userTaskService;

    //查询我完成的任务的方法
    @RequestMapping("selMyFinish")
    @ResponseBody
    public Result selMyFinish(HttpServletRequest request, HttpServletResponse response){
        int userid = Integer.parseInt(request.getParameter("id"));
        int page = Integer.parseInt(request.getParameter("pg"));
        List<TbUserTask> utList = userTaskService.selMyFinish(userid,page);
        int count = userTaskService.selMyFinishCount(userid);
        Result result = new Result();
        if(utList==null || utList.size()==0){
            result.setMessage("fail");
        }else{
            result.setMessage("success");
        }
        result.setList(utList);
        result.setCode(count);
        return result;
    }

}
